using Digitalmes.Domain.Entities.Mes.Qualities;

namespace Digitalmes.Application.Mes.Qulities.Defects.Commands;

/// <summary>
/// 缺陷定义删除命令。
/// </summary>
public sealed record DeleteDefectCommand(long Id) : IRequest<IResult<bool>>;

internal sealed class DeleteDefectCommandHandler(IRepository<QcDefectDefine> repo) : IRequestHandler<DeleteDefectCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteDefectCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.Id, cancellationToken);
        return Result.From(ok);
    }
}
